#coding:UTF-8
from tkinter import *

root=Tk()

text1=Text(root,width=30,height=5)
text1.pack()

text1.insert(INSERT,"gitee仓库~~~~~~~~~~~yep")
text1.tag_add("tag1","1.5","1.8","1.15")
text1.tag_config("tag1",background="yellow",foreground="red")

#新的tag会覆盖旧的tag（相同位置）
text1.tag_add("tag2","1.5","1.8","1.15")
text1.tag_config("tag2",foreground="green")

#改变tag 的优先级
text1.tag_lower("tag2")#另外一个py

#tag_bind(绑定事件)
mainloop()